import com.alibaba.fastjson.JSON;
import com.yang.spring.dao.IUserDao;
import com.yang.spring.model.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by dell on 2017/11/7.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/beans.xml"})
public class testUser {
    @Resource
    private IUserDao jdbcUserDao;

    @Test
    public void testAdd() {
        User u = new User("zhangsan", "123456", "张三");
        jdbcUserDao.add(u);

    }

    @Test
    public void testDelete() {
        jdbcUserDao.delete(2);
    }

    @Test
    public void testUpdate() {
        User u = new User("yhl", "111111", "杨汇琳");
        u.setId(2);
        jdbcUserDao.update(u);
    }

    @Test
    public void testLoad() {
        System.out.println(JSON.toJSONString(jdbcUserDao.load(1)));
    }

    @Test
    public void testList() {
        List<Map<String, Object>> list=jdbcUserDao.list();
        System.out.println(JSON.toJSONString(list));
    }
}
